package com.nicy.controller;

import com.nicy.utils.exception.BusinessRuntimeException;
import com.nicy.utils.exception.ResultCode;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/test")
public class TestExceptionController {
    /**
     * 测试返回异常信息
     * @return
     */
    @RequestMapping(value = "/exception",method = RequestMethod.GET)
    public String returnExceptionInfo() {

        if (1 != 2) {
            // 用户名错误或不存在异常
            throw new BusinessRuntimeException(ResultCode.USERNAME_ERROR);
        }

        return "success";
    }

}
